<template>
  <div class="container">
    <!-- 顶部栏 -->
    <g-header></g-header>
    <!-- 广告 -->
    <g-banner1 :img="data.ad.flash_img"></g-banner1>
    <!-- 主要内容 -->
    <div class="main-container">
      <!-- 导航栏 -->
      <g-nav :nav="data.detail.nav" :name="data.detail.belone_menu"></g-nav>
      <!-- 这个页面比较不一致，PC和wap 没办法写自适应，只能分开写，这个是PC -->
      <div class="content-container hidden-in-xs">
        <!-- 标题栏，有当前目录的名字和面包屑 -->
        <div class="title-container">
          <!-- 面包屑 -->
          <div class="hidden-in-xs breadcrumb">
            <span>当前位置：</span>
            <span>美梦首页></span>
            <span v-for="(item,index) in breadcrumb" :key="index">{{item.cate_name}}{{index==data.detail.breadcrumb.length-1?'':'>'}}</span>
          </div>
        </div>
        <!-- 商品内容 -->
        <div class="content">
          <!-- 商品轮播图 -->
          <div class="banner">
            <g-productBanner :img="data.detail.detail.goods_file_arr"></g-productBanner>
          </div>
          <!-- 商品信息 -->
          <div class="info">
            <p class="goods_name">{{data.detail.detail.goods_name}}</p>
            <p class="goods_price">建议零售价：{{data.detail.detail.goods_price.toFixed(2)}}</p>
            <p class="goods_describe">{{data.detail.detail.goods_describe}}</p>
            <p class="goods_contact">
              订购热线：{{data.detail.phone_number}}
            </p>
          </div>
          <p class="register_time">上市时间：{{data.detail.detail.register_date}} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 人气：{{data.detail.detail.goods_hit}}</p>
        </div>
        <!-- 商品详情 -->
        <div class="detail-container">
          <div class="title">
            详情介绍
          </div>
          <div class="border">
          </div>
          <div class="detail" v-html="data.detail.detail.goods_content">
          </div>
        </div>
      </div>
      <!-- 这个页面比较不一致，PC和WAP 没办法写自适应，只能分开写，这个是WAP -->      
      <div class="content-container xs-only">
        <!-- 商品标题 -->
        <div class="title-container">
          <p>{{data.detail.detail.goods_name}}</p>
          <p>建议零售价：{{data.detail.detail.goods_price.toFixed(2)}}</p>
        </div>
        <!-- 商品轮播图 -->
        <g-productBanner :img="data.detail.detail.goods_file_arr"></g-productBanner>
        <!-- 商品介绍 -->
        <p class="goods_describe">
          {{data.detail.detail.goods_describe}}
        </p>
        <!-- 分割线 -->
        <div class="demarcation"></div>
        <!-- 订购热线，这里取公司的号码 -->
        <p class="phone_number">
          订购热线：{{data.detail.phone_number}}
        </p>
        <!-- 发布时间 -->
        <p class="register_time">
          上市时间：{{data.detail.detail.register_date}} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 人气：{{data.detail.detail.goods_hit}}
        </p>
        <!-- 分割线 -->
        <div class="demarcation last"></div>
        <!-- 商品详情 -->
        <div class="detail-container">
          <p class="title">详情介绍</p>
          <div class="detail" v-html="data.detail.detail.goods_content"></div>
        </div>      
      </div>
    </div>
    <!-- 底部栏 -->
    <g-footer></g-footer>
  </div>
</template>

<script>
  import header from '@/components/header'
  import productBanner from '@/components/productBanner'
  import banner1 from '@/components/banner1'
  import nav from '@/components/nav'
  import footer from '@/components/footer'
  export default {
    components: {
      'g-header': header,
      'g-productBanner': productBanner,
      'g-banner1': banner1,
      'g-nav': nav,
      'g-footer': footer
    },
    data() {
      return {
        data: {}
      }
    },
    computed: {
       /**
       * @function 重新排序面包屑，后台传过来的是倒序
       */
      breadcrumb: function () {
        return this.data.detail.breadcrumb.reverse()
      },
    },
    created: function () {
      let that = this;
      this.$axios.get(this.$api+'/api/product' + that.getArgs)
        .then(function (response) {
          console.log(response);
          that.data = response.data;
        })
        .catch(function (response) {
          console.log(response);
        })
    },
  }

</script>
<style lang="less" scoped>
  @import url('../style/mixin.less');

  .main-container {
    width: 1200px;
    margin: 60px auto 0;
    .On-xs( {
      width: calc(100% - 20px);
      margin: 0 10px;
    }
    );
    .content-container.hidden-in-xs {
      width: 900px;
      margin-left: 20px;
      float: left;
      margin-bottom: 65px;
      border-bottom: 4px solid #a17657;
      .title-container {
        border-bottom: 4px solid #a17657;
        height: 76px;
        .title {
          float: left;
          height: 76px;
          line-height: 76px;
          font-family: MicrosoftYaHei;
          font-size: 20px;
          font-weight: normal;
          font-stretch: normal;
          letter-spacing: 1px;
          color: #543e2e;
          font-weight: bold;
        }
        .breadcrumb {
          float: left;
          line-height: 76px;
          font-size: 14px;
          font-weight: normal;
          font-stretch: normal;
          letter-spacing: 0px;
          color: #a17656;
          span:last-child {
            color: #543e2e;
          }
        }

      }
      .content {
        width: 100%;
        .banner {
          width: 530px;
          height: 420px;
          margin-top: 34px;
          margin-left: 10px;
          float: left;
        }
        .info {
          width: 300px;
          float: left;
          height: 420px;
          margin-top: 34px;
          margin-left: 30px;
          .goods_name {
            width: 100%;
            height: 20px;
            text-align: left;
            margin-top: 5px;
            font-size: 20px;
            font-weight: normal;
            font-stretch: normal;
            letter-spacing: 0px;
            color: #543e2e;
          }
          .goods_price {
            width: 100%;
            text-align: left;
            font-size: 22px;
            font-weight: normal;
            font-stretch: normal;
            line-height: 22px;
            letter-spacing: 0px;
            color: #543e2e;
            margin-top: 44px;
          }
          .goods_describe {
            width: 100%;
            height: 92px;
            font-family: MicrosoftYaHei;
            font-size: 16px;
            font-weight: normal;
            font-stretch: normal;
            line-height: 23px;
            letter-spacing: 0px;
            color: #a17657;
            margin-top: 15px;
            text-align: left;
            .Mult-line(4);
          }
          .goods_contact {
            width: 100%;
            text-align: left;
            font-size: 20px;
            font-weight: normal;
            font-stretch: normal;
            line-height: 20px;
            letter-spacing: 0px;
            color: #543e2e;
            margin-top: 111px;
          }
        }
        .register_time {
          float: left;
          width: 100%;
          height: 14px;
          text-align: left;
          font-size: 14px;
          font-weight: normal;
          font-stretch: normal;
          line-height: 14px;
          letter-spacing: 0px;
          color: #543e2e;
          text-indent: 10px;
          margin-top: 38px;
        }
      }
      .detail-container {
        width: 100%;
        float: left;
        margin-top: 38px;
        .title {
          width: 120px;
          height: 40px;
          background-color: #a17657;
          border-radius: 6px 6px 0px 0px;
          font-size: 16px;
          font-weight: normal;
          font-stretch: normal;
          line-height: 40px;
          text-align: center;
          letter-spacing: 0px;
          color: #ffffff;
        }
        .border {
          width: 100%;
          height: 2px;
          background-color: #a17657;
        }
        .detail {
          width: calc(100% - 20px);
          min-height: 200px;
          font-size: 16px;
          font-weight: normal;
          font-stretch: normal;
          line-height: 24px;
          letter-spacing: 0px;
          color: #a17657;
          text-align: left;
          margin: 33px 10px;
        }
      }
    }
    .content-container.xs-only {
      width: calc( 100% - 20px);
/*       height: 500px; */
      margin: 0 10px;
      text-align: left;
      border-bottom: 2px solid #a17656;
      margin-bottom: 20px;
      .title-container {
        height: 30px;
        width: 100%;
        p {
          width: calc(50% - 20px);
          margin: 0px 10px 0;
          float: left;
          font-size: 17px;
          font-weight: normal;
          font-stretch: normal;
          line-height: 30px;
          letter-spacing: 0px;
          color: #543e2e;
          font-weight: bold;
          overflow: hidden;
          height: 32px;
          &:last-child {
            text-align: right;
            font-size: 14px;
          }
        }
      }
      .goods_describe {
        width: calc(100% - 20px);
        margin: 0 10px;        
        height: 54px;
        font-family: MicrosoftYaHei;
        font-size: 13px;
        font-weight: normal;
        font-stretch: normal;
        line-height: 18px;
        letter-spacing: 0px;
        color: #a17656;
        margin-top: 26px;
        float: left;
        margin-bottom: 10px;
        .Mult-line(3);
      }
      .demarcation {
        height: 1px;
        width: calc(100% - 20px);
        background: #a17656;
        margin: 0 10px;
        float: left;
        &.last{
          width: 100%;
          height: 2px;
          margin: 0;
          margin-top: 22px;
        }
      }
      .phone_number {
        width: calc(100% - 20px);
        margin: 0 10px; 
        height: 12px;
        font-family: MicrosoftYaHei;
        font-size: 12px;
        font-weight: normal;
        font-stretch: normal;
        line-height: 12px;
        letter-spacing: 0px;
        color: #543e2e;
        margin-top: 16px;
        float: left;
        font-weight: bold;
      }
      .register_time {
        width: calc(100% - 20px);
        margin: 0 10px; 
        height: 11px;
        font-family: MicrosoftYaHei;
        font-size: 10px;
        font-weight: normal;
        font-stretch: normal;
        line-height: 11px;
        letter-spacing: 0px;
        color: #543e2e;
        margin-top: 16px;
        float: left;
      }
      .detail-container{
        width: 100%;
        padding: 20px 0;
        float: left;
        .title{
          width: calc(100% - 20px);
          margin: 0 10px; 
          height: 24px;
          font-family: MicrosoftYaHei;
          font-size: 14px;
          font-weight: normal;
          font-stretch: normal;
          line-height: 24px;
          letter-spacing: 0px;
          color: #543e2e;
          border-bottom: 1px solid #a17656;
          font-weight: bold;
        }
        .detail{
          width: calc(100% - 20px);
          margin: 0 10px; 
          *{
            width: 100% !important;
            max-width: 100% !important;
          }
        }
      }
    }
  }

</style>
